package net.oschina.app.adapter.my;

import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import net.oschina.app.R;
import net.oschina.app.adapter.BaseRecyclerViewAdapter;
import net.oschina.app.bean.Messages;
import net.oschina.app.databinding.MsgItemMsgBinding;

import java.util.List;

/**
 * Created by YL on 2017/4/5.
 */
public class ActiveLeaveMsgAdapter extends BaseRecyclerViewAdapter{
    /**
     * Created by YL on 2017/4/2.
     */
    private List<Messages> flist;

    public ActiveLeaveMsgAdapter(List<Messages> active) {
        this.flist = active;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = mInflater.inflate(R.layout.msg_item_msg, parent, false);
        ActiveViewHolder holder = new ActiveViewHolder(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        Messages msg = flist.get(position);
        MsgItemMsgBinding binding = DataBindingUtil.bind(holder.itemView);
        binding.setMsg(msg);
        binding.setImageUrl(msg.getPortrait());
        binding.setMessageCount(msg.getMessageCount()+"条留言");
    }

    @Override
    public int getItemCount() {
        return flist.size();
    }

    public class ActiveViewHolder extends RecyclerView.ViewHolder {

        public ActiveViewHolder(View itemView) {
            super(itemView);
        }
    }
}
